﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;

namespace TestDxfDocument
{
    class InsertsForReaming
    {
        public static void ReamingInsertWithOneCuttingEdgeAndDoublePlugChamfer(Dictionary<string, Object> data)  //单刃双切削锥铰孔刀片
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double offset = 10;
            double textHeight = 3.5;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            //double scale = 2; //放大系数


            double insl = Convert.ToDouble(data["insl"])*scale;
            double w1 = Convert.ToDouble(data["w1"])*scale ;
            double plgl1 = Convert.ToDouble(data["plgl1"]) * scale;
            double plgl2 = Convert.ToDouble(data["plgl2"]) * scale;
            double plgang1 = Convert.ToDouble(data["plgang1"]) * pi / 180;
            double plgang2 = Convert.ToDouble(data["plgang2"]) * pi / 180;
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double cbl = Convert.ToDouble(data["cbl"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            string path = Convert.ToString(data["path"]);
            
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, epsr, w1 / Math.Sin(epsr));
            Vector2 p2 = fun.Polar(p1, pi, insl);
            Vector2 p3p = fun.Polar(p0, pi, insl);
            Vector2 p5 = fun.Polar(p0, pi, insl - plgl1);
            Vector2 p4 = fun.Polar(p5, pi - plgang1, (plgl1 - plgl2) / Math.Cos(plgang1));
            Vector2 p3 = fun.Inters(p2, p3p, p4, fun.Polar(p4, pi - plgang2, 100));
            Vector2 p6 = fun.Polar(p0, epsr, cbl / Math.Sin(epsr));
            Vector2 p7 = fun.Polar(p6, pi, insl);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Vector2[] line1 = { p6, p7 };
            fun.drawBLine(dxf, line1, 0.1, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl * 1.2);
            Vector2 p11 = fun.Polar(p0p, pi - an, s / Math.Cos(an));
            Vector2 p12 = fun.Polar(p11, pi / 2, w1);
            Vector2 p13 = fun.Polar(p12, 0, s1);
            Vector2 p14 = new Vector2(p13.X, p0p.Y + cbl);
            Vector2 p15 = fun.Polar(p0p, pi / 2 + gan, 0.8 * cbl / Math.Cos(gan));

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes[4].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            Vector2 p17 = fun.Inters(p0p, p15, p4, fun.Polar(p4, 0, 100));
            Vector2 p16 = fun.Inters(p11, p12, p17, fun.Polar(p17, pi - an, 100));
            Vector2[] line2 = { p16, p17 };
            fun.drawBLine(dxf, line2, 0.1, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = textHeight;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = textHeight;

            LinearDimension linedim1 = new LinearDimension(new Line(p1, p2), offset, 0, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl/scale);
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p3p, p5), offset * 2, 180, dimensionStyle);
            linedim2.UserText = String.Format("PLGL1={0}", plgl1/scale );
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p3p, p4), offset, 180, dimensionStyle);
            linedim3.UserText = String.Format("PLGL2={0}", plgl2/scale );
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p0, p1), offset, 270, dimensionStyle);
            linedim4.UserText = String.Format("W1={0}", w1/scale );
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p12, p13), offset, 0, dimensionStyle);
            linedim5.UserText = String.Format("S1={0}", s1/scale);
            dxf.AddEntity(linedim5);

            LinearDimension linedim6 = new LinearDimension(new Line(p0p, p11), offset, 180, dimensionStyle);
            linedim6.UserText = String.Format("S={0}", s/scale );
            dxf.AddEntity(linedim6);

            LinearDimension linedim7 = new LinearDimension(new Line(p0p, p14), offset, 270, dimensionStyle);
            linedim7.UserText = String.Format("CBL={0}", cbl/scale );
            dxf.AddEntity(linedim7);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ReamingInsertWithTwoCuttingEdgesAndDoublePlugChamfer(Dictionary<string, Object> data)  //双刃双切削锥铰孔刀片
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double offset = 10;
            double textHeight = 3.5;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            //double scale = 2; //放大系数


            double insl = Convert.ToDouble(data["insl"])*scale ;
            double w1 = Convert.ToDouble(data["w1"])*scale ;
            double plgl1 = Convert.ToDouble(data["plgl1"]) * scale;
            double plgl2 = Convert.ToDouble(data["plgl2"]) * scale;
            double plgang1 = Convert.ToDouble(data["plgang1"]) * pi / 180;
            double plgang2 = Convert.ToDouble(data["plgang2"]) * pi / 180;
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            double s = Convert.ToDouble(data["s"]) * scale;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double cbl = Convert.ToDouble(data["cbl"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            string path = Convert.ToString(data["path"]);
            
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, epsr, w1 / Math.Sin(epsr));
            Vector2 p2 = fun.Polar(p1, pi, insl);
            Vector2 p3 = fun.Polar(p0, pi, insl);
            Vector2 p4 = fun.Polar(p0, pi, insl - plgl1);
            Vector2 p5 = fun.Polar(p4, pi - plgang1, (plgl1 - plgl2) / Math.Cos(plgang1));
            Vector2 p6 = fun.Inters(p2, p3, p4, fun.Polar(p4, pi - plgang2, 100));
            Vector2 p13 = fun.Polar(p0, epsr, cbl / Math.Sin(epsr));
            Vector2 p7 = fun.Polar(p13, pi, insl);
            Vector2 p8 = fun.Polar(p2, pi + epsr, cbl / Math.Sin(epsr));
            Vector2 p9 = fun.Polar(p2, 0, insl - plgl1);
            Vector2 p10 = fun.Polar(p9, -plgang1, (plgl1 - plgl2) / Math.Cos(plgang1));
            Vector2 p11 = fun.Inters(p0, p1, p10, fun.Polar(p10, -plgang2, 100));
            Vector2 p12 = fun.Polar(p8, 0, insl);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Vector2[] line1 = { p7, p13 };
            fun.drawBLine(dxf, line1, 0.1, contour);
            Vector2[] line2 = { p8, p12 };
            fun.drawBLine(dxf, line2, 0.1, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl * 1.2);
            Vector2 p21 = fun.Polar(p0p, pi - an, s / Math.Cos(an));
            Vector2 p23 = fun.Polar(p0p, 0.5 * pi, w1);
            Vector2 p22 = fun.Polar(p23, pi + an, s / Math.Cos(an));
            Vector2 p24 = fun.Polar(p23, 1.5 * pi - gan, 0.7 * cbl);
            Vector2 p25 = new Vector2(p21.X + s1, p23.Y - cbl);
            Vector2 p26 = new Vector2(p21.X + s1, p0p.Y + cbl);
            Vector2 p27 = fun.Polar(p0p, 0.5 * pi + gan, 0.7 * cbl);
            Vector2 p30 = fun.Inters(p0p, p27, p5, fun.Polar(p5, 0, 100));
            Vector2 p31 = fun.Inters(p21, p22, p30, fun.Polar(p30, pi - an, 100));

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            poly2.Vertexes.Add(new LwPolylineVertex(p22));
            poly2.Vertexes.Add(new LwPolylineVertex(p23));
            poly2.Vertexes.Add(new LwPolylineVertex(p24));
            poly2.Vertexes[4].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes[6].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p27));
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            Vector2[] line3 = { p30, p31 };
            fun.drawBLine(dxf, line3, 0.1, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = textHeight;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = textHeight;
            
            LinearDimension linedim1 = new LinearDimension(new Line(p2, p11), offset+Math .Abs (p2.Y-p11.Y)/2, 0, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl / scale);
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p0, p9), offset +Math .Abs (p0.X-p9.X)/2, 270, dimensionStyle);
            linedim2.UserText = String.Format("W1={0}", w1/scale );
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p5, p3), offset, 180, dimensionStyle);
            linedim3.UserText = String.Format("PLGL2={0}", plgl2/scale );
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p4, p3), offset * 2, 180, dimensionStyle);
            linedim4.UserText = String.Format("PLGL1={0}", plgl1 / scale);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p22, p25), offset+Math .Abs (p22.Y-p25.Y)/2, 0, dimensionStyle);
            linedim5.UserText = String.Format("S1={0}", s1 / scale);
            dxf.AddEntity(linedim5);

            LinearDimension linedim6 = new LinearDimension(new Line(p0p, p21), offset, 180, dimensionStyle);
            linedim6.UserText = String.Format("S={0}", s / scale);
            dxf.AddEntity(linedim6);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ReamingInsertWithOneCuttingEdgeAndRoundedCorner(Dictionary<string, Object> data)  //单刃圆角铰孔刀片
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double offset = 10;
            double textHeight = 3.5;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            //double scale = 2; //放大系数

            double insl = Convert.ToDouble(data["insl"]) * scale;
            double w1 = Convert.ToDouble(data["w1"]) * scale;
            double plgl1 = Convert.ToDouble(data["plgl1"]) * scale;
            double re = Convert.ToDouble(data["re"]) * scale;
            double plgang1 = Convert.ToDouble(data["plgang1"]) * pi / 180;
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double cbl = Convert.ToDouble(data["cbl"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            string path = Convert.ToString(data["path"]);
            
            double length1 = (plgl1 * Math.Sin(epsr)) / Math.Sin(pi - epsr - plgang1);
            double length2 = (plgl1 * Math.Sin(plgang1)) / Math.Sin(pi - epsr - plgang1);
            double ang1 = 0.5 * (pi - epsr - plgang1);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, epsr, w1 / Math.Sin(epsr));
            Vector2 p2 = fun.Polar(p1, pi, insl);
            Vector2 p3 = fun.Polar(p0, pi, insl);
            Vector2 p4 = fun.Polar(p0, pi, insl - plgl1 );
            Vector2 p5 = fun.Polar(p4, pi - plgang1, length1 - re * Math.Tan(ang1));
            Vector2 p6 = fun.Polar(p3, epsr, length2 + re * Math.Tan(ang1));
            Vector2 p8 = fun.Polar(p0, epsr, cbl / Math.Sin(epsr));
            Vector2 p7 = fun.Polar(p8, pi, insl);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes[3].Bulge = Math.Tan((pi - epsr - plgang1) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Vector2[] line1 = { p7, p8 };
            fun.drawBLine(dxf, line1, 0.1, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl);
            Vector2 p11 = fun.Polar(p0p, pi - an, s / Math.Cos(an));
            Vector2 p12 = new Vector2(p11.X, p0p.Y + w1);
            Vector2 p13 = fun.Polar(p12, 0, s1);
            Vector2 p14 = fun.Polar(p13, 1.5 * pi, w1 - cbl);
            Vector2 p15 = fun.Polar(p0p, 0.5 * pi + gan, 0.7 * cbl);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes[4].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = textHeight;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = textHeight;

            LinearDimension linedim1 = new LinearDimension(new Line(p1, p2), offset, 0, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl/scale );
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p3, p4), offset, 180, dimensionStyle);
            linedim2.UserText = String.Format("PLGL1={0}", plgl1/scale );
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p0, p1), offset, 270, dimensionStyle);
            linedim3.UserText = String.Format("W1={0}", w1 / scale);
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p12, p13), offset, 0, dimensionStyle);
            linedim4.UserText = String.Format("S1={0}", s1 / scale);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p0p, p11), offset, 180, dimensionStyle);
            linedim5.UserText = String.Format("S={0}", s / scale);
            dxf.AddEntity(linedim5);

            LinearDimension linedim6 = new LinearDimension(new Line(p0p, p14), offset, 270, dimensionStyle);
            linedim6.UserText = String.Format("CBL={0}", cbl / scale);
            dxf.AddEntity(linedim6);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);


            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ReamingInsertWithTwoCuttingEdgesAndRoundedCorner(Dictionary<string, Object> data)  //双刃圆角铰孔刀片
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double offset = 10;
            double textHeight = 3.5;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            //double scale = 2; //放大系数

            double insl = Convert.ToDouble(data["insl"]) * scale;
            double w1 = Convert.ToDouble(data["w1"]) * scale;
            double plgl1 =Convert.ToDouble(data["plgl1"]) * scale;
            double re = Convert.ToDouble(data["re"]) * scale;
            double plgang1 = Convert.ToDouble(data["plgang1"]) * pi / 180;
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double cbl = Convert.ToDouble(data["cbl"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            string path =  Convert.ToString(data["path"]);
            
            double length1 = (plgl1 * Math.Sin(epsr)) / Math.Sin(pi - epsr - plgang1);
            double length2 = (plgl1 * Math.Sin(plgang1)) / Math.Sin(pi - epsr - plgang1);
            double ang1 = 0.5 * (pi - epsr - plgang1);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, epsr, w1 / Math.Sin(epsr));
            Vector2 p2 = fun.Polar(p1, pi, insl);
            Vector2 p3 = fun.Polar(p0, pi, insl);
            Vector2 p4 = fun.Polar(p0, pi, insl - plgl1);
            Vector2 p5 = fun.Polar(p4, pi - plgang1, length1 - re * Math.Tan(ang1));
            Vector2 p6 = fun.Polar(p3, epsr, length2 + re * Math.Tan(ang1));
            Vector2 p7 = fun.Polar(p2, 0, insl - plgl1);
            Vector2 p8 = fun.Polar(p7, -plgang1, length1 - re * Math.Tan(ang1));
            Vector2 p9 = fun.Polar(p1, pi + epsr, length2 + re * Math.Tan(ang1));
            Vector2 p10 = fun.Polar(p0, epsr, cbl / Math.Sin(epsr));
            Vector2 p11 = fun.Polar(p10, pi, insl);
            Vector2 p12 = fun.Polar(p2, pi + epsr, cbl / Math.Sin(epsr));
            Vector2 p13 = fun.Polar(p12, 0, insl);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes[1].Bulge = Math.Tan((pi - epsr - plgang1) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes[5].Bulge = Math.Tan((pi - epsr - plgang1) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Vector2[] line1 = { p10, p11 };
            fun.drawBLine(dxf, line1, 0.1, contour);
            Vector2[] line2 = { p12, p13 };
            fun.drawBLine(dxf, line2, 0.1, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl);
            Vector2 p21 = fun.Polar(p0p, pi - an, s / Math.Cos(an));
            Vector2 p23 = fun.Polar(p0p, 0.5 * pi, w1);
            Vector2 p22 = fun.Polar(p23, pi + an, s / Math.Cos(an));
            Vector2 p24 = fun.Polar(p23, 1.5 * pi - gan, 0.7 * cbl);
            Vector2 p25 = new Vector2(p21.X + s1, p12.Y);
            Vector2 p26 = new Vector2(p25.X, p10.Y);
            Vector2 p27 = fun.Polar(p0p, 0.5 * pi + gan, 0.7 * cbl);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            poly2.Vertexes.Add(new LwPolylineVertex(p22));
            poly2.Vertexes.Add(new LwPolylineVertex(p23));
            poly2.Vertexes.Add(new LwPolylineVertex(p24));
            poly2.Vertexes[4].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes[6].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p27));
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            DimensionStyle dimensionStyle = fun.DimStyle(true);
            DimensionStyle dimensionStyle2 = fun.DimStyle(false);


            LinearDimension linedim1 = new LinearDimension(new Line(p2, p9), offset, 0, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl / scale);
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p3, p4), offset+Math .Abs (p3.Y-p4.Y)/2, 180, dimensionStyle);
            linedim2.UserText = String.Format("PLGL1={0}", plgl1 / scale);
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p0, p7), offset+Math.Abs (p0.X-p7.X)/2, 270, dimensionStyle);
            linedim3.UserText = String.Format("W1={0}", w1 / scale);
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p22, p25), offset, 0, dimensionStyle);
            linedim4.UserText = String.Format("S1={0}", s1 / scale);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p0p, p21), offset, 180, dimensionStyle);
            linedim5.UserText = String.Format("S={0}", s / scale);
            dxf.AddEntity(linedim5);

            LinearDimension linedim6 = new LinearDimension(new Line(p0p, p26), offset+Math.Abs (p0p.X-p26.X)/2, 270, dimensionStyle2);
            linedim6.UserText = String.Format("CBL={0}", cbl / scale);
            dxf.AddEntity(linedim6);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ReamingInsertWithSpecialCuttingProfile(Dictionary<string, Object> data)  //特殊切削剖面的铰孔刀片
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double offset = 10;
            double textHeight = 3.5;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            //double scale = 2; //放大系数

            double insl = Convert.ToDouble(data["insl"]) * scale;
            double ced1 = Convert.ToDouble(data["ced1"]) * scale;
            double ced2 = Convert.ToDouble(data["ced2"]) * scale;
            double w1 = Convert.ToDouble(data["w1"]) * scale;
            double plgl = Convert.ToDouble(data["plgl"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sdl2 = Convert.ToDouble(data["sdl2"]) * scale;
            double sd2 = Convert.ToDouble(data["sd2"]) * scale;
            double sd3 = Convert.ToDouble(data["sd3"])*scale ;
            double epsr = Convert.ToDouble(data["epsr"]) * pi / 180;
            double plgang = Convert.ToDouble(data["plgang"]) * pi / 180;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;
            double s = Convert.ToDouble(data["s"]) * scale;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double cbl = Convert.ToDouble(data["cbl"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            string path = Convert.ToString(data["path"]);
            
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, epsr, w1 / Math.Sin(epsr));
            Vector2 p2 = fun.Polar(p1, pi, insl);
            Vector2 p3 = fun.Polar(p0, pi, insl);
            Vector2 p4 = fun.Polar(p3, 0, sd3);
            Vector2 p5 = fun.Polar(p4, pi - sta3, (sd3 - sd2 - sdl2) / Math.Cos(sta3));
            Vector2 p6 = fun.Polar(p5, pi, sdl2);
            Vector2 p7 = fun.Polar(p6, pi - sta2, (sd2 - plgl - sdl1) / Math.Cos(sta2));
            Vector2 p8 = fun.Polar(p7, pi, sdl1);
            Vector2 p9 = fun.Polar(p8, pi - plgang, plgl / Math.Cos(plgang));
            Vector2 p10 = fun.Polar(p0, epsr, cbl / Math.Sin(epsr));
            Vector2 p11 = fun.Polar(p10, pi, insl);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Vector2[] line1 = { p10, p11 };
            fun.drawBLine(dxf, line1, 0.1, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl);
            Vector2 p21 = fun.Polar(p0p, pi - an, s / Math.Cos(an));
            Vector2 p22 = new Vector2(p0p.X - s, p0p.Y + w1);
            Vector2 p23 = fun.Polar(p22, 0, s1);
            Vector2 p24 = fun.Polar(p23, 1.5 * pi, w1 - cbl);
            Vector2 p25 = fun.Polar(p0p, 0.5 * pi + gan, 0.7 * cbl);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            poly2.Vertexes.Add(new LwPolylineVertex(p22));
            poly2.Vertexes.Add(new LwPolylineVertex(p23));
            poly2.Vertexes.Add(new LwPolylineVertex(p24));
            poly2.Vertexes[4].Bulge = Math.Tan(pi / 7);
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes.Add(new LwPolylineVertex(p0p));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            DimensionStyle dimensionStyle = fun.DimStyle(true);
            DimensionStyle dimensionStyle2 = fun.DimStyle(false);

            LinearDimension linedim1 = new LinearDimension(new Line(p1, p2), offset, 0, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl/scale );
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p2, p8), offset, 90, dimensionStyle);
            linedim2.SetDimensionLinePosition(new Vector2 (p2.X-offset,p2.Y));
            linedim2.UserText = String.Format("CED1={0}", ced1/scale );
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p2, p6), offset * 2, 90, dimensionStyle);
            linedim3.SetDimensionLinePosition(new Vector2(p2.X - offset*2, p2.Y));
            linedim3.UserText = String.Format("CED2={0}", ced2 / scale);
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p8, p9), offset, 180, dimensionStyle2);
            linedim4.SetDimensionLinePosition(new Vector2(p6.X , p6.Y-offset));
            linedim4.UserText = String.Format("PLG1={0}", plgl / scale);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p7, p8), offset, 180, dimensionStyle);
            linedim5.SetDimensionLinePosition(new Vector2(p6.X, p6.Y - offset));
            linedim5.UserText = String.Format("SDL1={0}", sdl1);
            dxf.AddEntity(linedim5);

            LinearDimension linedim6 = new LinearDimension(new Line(p6, p9), offset * 2, 180, dimensionStyle);
            linedim6.SetDimensionLinePosition(new Vector2(p6.X, p6.Y - offset*2));
            linedim6.UserText = String.Format("SD2={0}", sd2 / scale);
            dxf.AddEntity(linedim6);

            LinearDimension linedim7 = new LinearDimension(new Line(p5, p6), offset * 2, 180, dimensionStyle);
            linedim7.SetDimensionLinePosition(new Vector2(p6.X, p6.Y - offset * 2));
            linedim7.UserText = String.Format("SDL2={0}", sdl2 / scale);
            dxf.AddEntity(linedim7);

            LinearDimension linedim8 = new LinearDimension(new Line(p4, p9), offset * 3, 180, dimensionStyle);
            linedim8.SetDimensionLinePosition(new Vector2(p6.X, p6.Y - offset * 3));
            linedim8.UserText = String.Format("SD3={0}", sd3 / scale);
            dxf.AddEntity(linedim8);

            LinearDimension linedim9 = new LinearDimension(new Line(p0, p1), offset, 270, dimensionStyle);
            linedim9.UserText = String.Format("W1={0}", w1 / scale);
            dxf.AddEntity(linedim9);

            LinearDimension linedim10 = new LinearDimension(new Line(p22, p23), offset, 0, dimensionStyle);
            linedim10.UserText = String.Format("S1={0}", s1);
            dxf.AddEntity(linedim10);

            LinearDimension linedim11 = new LinearDimension(new Line(p0p, p21), offset, 180, dimensionStyle);
            linedim11.UserText = String.Format("S={0}", s / scale);
            dxf.AddEntity(linedim11);

            LinearDimension linedim12 = new LinearDimension(new Line(p0p, p24), offset, 270, dimensionStyle);
            linedim12.UserText = String.Format("CBL={0}", cbl / scale);
            dxf.AddEntity(linedim12);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

    }
}
